<?php

class Model_User extends Model_Connections {

    public function validateUserByUserName($userName, $passWord) {
        if ($userName == null || $userName == "" 
                || $passWord == null || $passWord == ""){
            return false;
        }
            
        $auth = Zend_Auth::getInstance();
        $authAdapter = new Zend_Auth_Adapter_DbTable($db);

        $authAdapter->setTableName('user')
                ->setIdentityColumn('username')
                ->setCredentialColumn('password');

        $authAdapter->setIdentity($userName);
        $authAdapter->setCredential($passWord);

        $result = $auth->authenticate($authAdapter);

        if ($result->isValid()) {
            $data = $authAdapter->getResultRowObject(null, array('password'));
            $auth->getStorage()->write($data);    
            return true;
        }else{
            return false;
        }

        
    }

}

?>